

<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" style="height: 300px">
    <div class="layui-card-body padding-left-20">
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-sm margin-bottom-10" type="button" onclick="addSku()">新增会员卡</button>
            <div class="card_list">
            <!--循环规格-->
                {foreach $viplist as $sdk=>$sdv}
                    <div style="display:inline-block; position:relative;" class="border-line padding-20 margin-right-10 pull-left sku_detail">
                        <div style="position:absolute;right:10px;top: 0;color:red;cursor:pointer;" class="close" >X</div>
                         <label class="layui-form-item block relative">
                            <span class="help-label"><b>会员卡名称</b></span>
                            <input class="layui-input" name="name[]" placeholder="请输入会员卡名称" required value="{$sdv.name|default=''}">
                        </label>
                        <label class="layui-form-item block relative">
                            <span class="help-label"><b>会员卡价格</b></span>
                            <input class="layui-input" name="amount[]" placeholder="请输入会员卡价格" required value="{$sdv.amount|default=''}">
                        </label>
                        <label class="layui-form-item block relative">
                            <span class="help-label"><b>会员卡类型</b></span>
                            <select class="layui-select" lay-search name="type[]">
                                {foreach ['年卡','次卡'] as $k=>$cate}{if $k eq $sdv.type}
                                <option selected value="{$k}">{$cate}</option>
                                {else}
                                <option value="{$k}">{$cate}</option>
                                {/if}{/foreach}
                            </select>
                        </label>
                        <label class="layui-form-item block relative">
                            <span class="help-label"><b>会员卡描述</b></span>
                            <textarea class="layui-textarea" name="remark[]" placeholder="请输入会员卡描述">{$sdv.remark|default=''}</textarea>
                        </label>
                    </div>
                {/foreach}
            </div>
        </div>

        <div class="layui-form-item text-center">
            <button class="layui-btn layui-btn-xs" type="submit">保存</button>
        </div>
    </div>
</form>

<script>
        Close();
        function Close(){
            $(".close").unbind().on('click',function(){
                $(this).parent().remove();
            })
        }
        function addSku(){
            var _html = '<div style="display:inline-block; position:relative;" class="border-line padding-20 margin-right-10 pull-left sku_detail">';
                _html+='<div style="position:absolute;right:10px;top: 0;color:red;cursor:pointer;" class="close" >X</div>';
                _html+='<label class="layui-form-item block relative">';
                _html+='<span class="help-label"><b>会员卡名称</b></span>';
                _html+='<input class="layui-input" name="name[]" placeholder="请输入会员卡名称" required value="">';
                _html+='</label>';
                _html+='<label class="layui-form-item block relative">';
                _html+='<span class="help-label"><b>会员卡价格</b></span>';
                _html+='<input class="layui-input" name="amount[]" placeholder="请输入会员卡价格" required value="">';
                _html+='</label>';
                _html+='<label class="layui-form-item block relative">';
                _html+='<span class="help-label"><b>会员卡类型</b></span>';
                _html+='<select class="layui-select" lay-search name="type[]">';
                var card = ['年卡','次卡'];
                $.each(card,function(i,v){
                    _html += '<option value="'+i+'">'+v+'</option>';
                })
                _html+='</select>';
                _html+='</label>';
                _html+='<label class="layui-form-item block relative">';
                _html+='<span class="help-label"><b>会员卡描述</b></span>';
                _html+='<textarea class="layui-textarea" name="remark[]" placeholder="请输入会员卡描述"  value=""></textarea>';
                _html+='</label>';
                _html+='</div>';
                $(".card_list").append(_html);
                $("form").parents(".layui-layer-content").css("height",'485px');
                $("form").parents(".layui-layer-content").css("overflow",'scroll');
                form.render();
                Close();
        }
</script>
